package com.yune.adapter;
import android.app.Activity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
import com.yune.R;
import com.yune.utils.Network;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.util.List;
public class DownloadListAdapter extends ArrayAdapter<String> {
    private static final int layoutId = R.layout.item_download;
    public DownloadListAdapter(Activity context, List<String> objects){
        super(context,layoutId,objects);
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent){
        String path = getItem(position);
        View view;
        ViewHolder viewHolder;
        if (convertView==null){
            view=LayoutInflater.from(getContext()).inflate(layoutId,parent,false);
            viewHolder= new ViewHolder();
            viewHolder.title=view.findViewById(R.id.download_item_title);
            view.setTag(viewHolder);
        } else{
            view=convertView;
            viewHolder=(ViewHolder) view.getTag();
        }
        viewHolder.title.setText(new File(path).getName().replace(".mp3",""));
        return view;
    }
    static class ViewHolder{
        TextView title;
    }
}